<?php
include_once("../modules/checkA.php");
include_once("../../config.php"); 
$plate=select_one_line_all_items($table_Prefix."plate","mid = 'member'");
?>


<?
//用来判断当前系统属于什么板块
$system_part = $plate['mid'];
include_once("detail-list-function.php"); 
?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include ROOT_PATH_.'/controller/common/module/head.php'; ?>
    <?php include 'modules/head.php'; ?>
</head>

<body>
 



 
<?php


$new_name         = addslashes($_REQUEST['name']);
$new_idnumber     = addslashes($_REQUEST['idnumber']);
$new_sex          = addslashes($_REQUEST['sex']);
$new_phone        = addslashes($_REQUEST['phone']);
$new_cost         = addslashes($_REQUEST['cost']);
$new_status       = addslashes($_REQUEST['status']);
$new_license      = addslashes($_REQUEST['license']);
$new_remark       = addslashes($_REQUEST['remark']);
$new_applydate    = date(Y . '-' . m . '-' . d . ' ' . H . '-' . i . '-' . s);
$new_authur       = $_SESSION['username'];

$new_departmentid = $_SESSION['departmentid'];

$new_agentid       = addslashes($_REQUEST['agentid']);
$new_coachid       = addslashes($_REQUEST['coachid']);
$new_address       = addslashes($_REQUEST['address']);




//设置需要搜索的表格的前缀后缀
$table_Suffix = "member";
$table = $table_Prefix . $table_Suffix;
//设置需要搜索的表格的前缀后缀
 
 

$sql = "INSERT INTO $table (
name,  
idnumber,
sex,
phone,
cost,
status,
license,
agentid,
applydate,
authur,
departmentid,
coachid,
address,
remark
)

value (
'$new_name',
'$new_idnumber',
'$new_sex',
'$new_phone',
'$new_cost',
'$new_status',
'$new_license',
'$new_agentid',
'$new_applydate',
'$new_authur',
'$new_departmentid',
'$new_coachid',
'$new_address',
'$new_remark'
)";


$query = mysql_query($sql) or die ('添加学员信息失败！');



//插入会员信息之后，就立刻根据身份证和名字读取信息，作为财务信息的masterid
$master=select_one_line_all_items($table,"name ='".$new_name."' and idnumber = '".$new_idnumber."'");




//设置需要搜索的表格的前缀后缀
$table_Suffix = "finance";
$table = $table_Prefix . $table_Suffix;
//设置需要搜索的表格的前缀后缀





$new_applydate    = date("Y-m-d H:i:s");
$new_classify     = "学费收款";
$ip               = $_SERVER["REMOTE_ADDR"];
$new_authur       = $_SESSION['nid'];
$new_remark       = "报名生成信息";
$masterid         = $master['nid'];



$sql_finance = "INSERT INTO $table (
name,
departmentid,
cost,
status,
applydate,
classify,
authur,
ip,
masterid,
remark
)

value (
'$new_name',
'$new_departmentid',
'$new_cost',
'$new_status',
'$new_applydate',
'$new_classify',
'$new_authur',
'$ip',
'$masterid',
'$new_remark'
)";


//加一道防御，如果缺少必要信息，就不能添加信息上去哦
if($_SESSION['username'])
{
$query = mysql_query($sql) or die ('添加报名信息失败！');


if($_REQUEST['status']=="已收款")
{
$query2 = mysql_query($sql_finance) or die ('添加财务信息失败！');
}

}
else
{
    echo "请登录后进行操作";
}

mysql_close($con);

 
?>

<!---->
<?//if($new_status=="已收款"){?>
<!--    <script type="text/javascript">-->
<!--        alert("输入信息已保存，点击确认打印收据.");-->
<!--        window.open("receipt.php?nav-itemed=member&nid=102');-->
<!--    </script>-->
<?//}else{?>
    <script type="text/javascript">
       alert("输入信息已保存，点击确认返回继续操作.");
        document.location.href = "detail-list.php?nav-itemed=member";
    </script>
<?//}?>
<!---->


</body>